#include <iostream>
#define N 100

using namespace std;

// interface for 2D array
void printVector(int array[], int elements){
for(int i=0; i<elements; i++){
	cout<<array[i]<<" ";}
	cout<<"\n";
}

int main(){
int row;
int column;
int matrix[N][N];
int array[N];
int elements=0;
int i,j;

cout<<"Type the number of rows: " ;
cin>>row;

cout<<"Type the number of columns: " ;
cin>>column;

cout<<"Enter matrix elements:"<<endl;
for(i=0;i<row;i++)
    for(j=0;j<column;j++){
        cout<<"["<<i<<"]["<<j<<"]= ";
        cin>>matrix[i][j];}
for (i=0;i<row;++i)
    if(i%2==0)
        for(j=0;j<column;++j){
            array[elements]=matrix[i][j];
				elements++;}
    else
        for(j=column-1; j>=0; --j){
            array[elements]=matrix[i][j];
				elements++;}

cout<<"Elements from right column to left column are: "<<endl;
printVector(array, elements);

return 0;
}
